<template>
 <van-nav-bar fixed :title="title" :right-text="rightText" left-arrow @click-left="leftClick" @click-right="rightClick"></van-nav-bar>
</template>

<script lang="ts" setup>
const props = defineProps<{title?:string;rightText?:string;back?:()=>void}>()
const router = useRouter()
const emit = defineEmits< {(event: 'leftClick'): void
  (event: 'rightClick'): void}>()
const leftClick=()=>{
  // emit('leftClick')
  if(props.back) return props.back()
  if(history.state?.back){
  router.back()
}else{
  router.push('/')
}
}
const rightClick=()=>{
  emit('rightClick')
}
</script>

<style lang="scss" scoped>
:deep() {
  .van-nav-bar {
    &__arrow {
      font-size: 18px;
      color: var(--cp-text1);
    }
    &__text {
      font-size: 15px;
    }
  }
}

</style>